package com.ljw.test.model;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Transient;

import java.util.Objects;

@Entity
public class Child {
    @Id
    Long id;

    @NotNull
    Long parentId;

    @NotNull
    String child;

    @NotNull
    int time;

    @Transient
    int preLength;

    @Generated(hash = 1916877936)
    public Child(Long id, @NotNull Long parentId, @NotNull String child, int time) {
        this.id = id;
        this.parentId = parentId;
        this.child = child;
        this.time = time;
    }

    public Child(String child, int pre) {
        this.child = child;
        this.preLength = pre;
    }

    @Generated(hash = 891984724)
    public Child() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getParentId() {
        return this.parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getChild() {
        return this.child;
    }

    public void setChild(String child) {
        this.child = child;
    }

    public int getTime() {
        return this.time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public int getPreLength() { return preLength; }

    public void setPreLength(int preLength) { this.preLength = preLength; }

    @Override
    public String toString() {
        return "Child{" +
                "id=" + id +
                ", parentId=" + parentId +
                ", child='" + child + '\'' +
                ", time=" + time +
                '}';
    }

//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (!(o instanceof Child)) return false;
//
//        Child child1 = (Child) o;
//
//        return getChild().equals(child1.getChild());
//    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Child child1 = (Child) o;

        if (id != null ? !id.equals(child1.id) : child1.id != null) return false;
        return child != null ? child.equals(child1.child) : child1.child == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (child != null ? child.hashCode() : 0);
        return result;
    }
}
